package com.cuihanyu.newuniversityover.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.cuihanyu.newuniversityover.R;
import com.cuihanyu.newuniversityover.bean.HomeEXDetailBean;

import java.util.List;

/**
 * Created by 崔汉宇 on 2017/8/8.
 */

public class HomeExpandableListViewAdapter extends BaseExpandableListAdapter {
    Activity activity;
    List<HomeEXDetailBean.MiniArrayBean> list;
    private TextView textView;
    private ImageView imageView;

    public HomeExpandableListViewAdapter(Activity activity, List<HomeEXDetailBean.MiniArrayBean> list) {
        this.activity = activity;
        this.list = list;
    }

    @Override
    public int getGroupCount() {
        return list != null ? list.size() : 0;
    }

    @Override
    public int getChildrenCount(int i) {
        return list.get(i).getBars() != null ? list.get(i).getBars().size() : 0;
    }

    @Override
    public Object getGroup(int i) {
        return null;
    }

    @Override
    public Object getChild(int i, int i1) {
        return null;
    }

    @Override
    public long getGroupId(int i) {
        return 0;
    }

    @Override
    public long getChildId(int i, int i1) {
        return 0;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {
        view = View.inflate(activity, R.layout.homelist_it, null);
        textView = view.findViewById(R.id.liebiao);
        textView.setText(list.get(i).getTitle());
        return view;
    }

    @Override
    public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) {
        view = View.inflate(activity, R.layout.homelist_it_it, null);
        TextView textView1 = view.findViewById(R.id.liebiao_it);
        textView1.setText(list.get(i).getBars().get(i1).getTitle());
        return view;
    }

    @Override
    public boolean isChildSelectable(int i, int i1) {
        return true;
    }
}
